//
//  AppDelegate.m
//  DontRem
//
//  Created by apple on 2021/1/15.
//

#import "AppDelegate.h"
#import "YZAuthID.h"
#import <IQKeyboardManager/IQKeyboardManager.h>
#import "DLMainViewVC.h"
#import "BXNavigationController.h"
@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    IQKeyboardManager *manager = [IQKeyboardManager sharedManager];
    manager.enable = YES;//控制整个功能是否启用。
    manager.shouldResignOnTouchOutside = YES;//控制点击背景是否收起键盘
    manager.shouldShowToolbarPlaceholder = YES;//中间位置是否显示占位文字
    manager.placeholderFont = [UIFont boldSystemFontOfSize:16];//设置占位文字的字体
    manager.enableAutoToolbar = YES;//控制是否显示键盘上的工具条。
    
    [self launchApp];
    return YES;
}
-(void)launchApp{
    NSString * flag = iPhoneX?[DLUserDefaultModel userDefaultsModel].faceIdentify : [DLUserDefaultModel userDefaultsModel].thumbIdentify;
    if ([flag isEqualToString:@"YES"]) {
        [self authIDVerify];
    }else{
        [self gotoMainView];
    }
}
-(void)gotoMainView{
    DLMainViewVC * vc = [DLMainViewVC new];
    BXNavigationController * nav = [[BXNavigationController alloc]initWithRootViewController:vc];
    self.window.rootViewController = nav;
}
-(void)authIDVerify{
    [[YZAuthID alloc] yz_showAuthIDWithDescribe:nil block:^(YZAuthIDState state, NSError *error) {
        if (state == YZAuthIDStateNotSupport) {
            XHQHUDErrorText(@"对不起，当前设备不支持指纹/面部ID");
        } else if(state == YZAuthIDStateFail) {
            XHQHUDErrorText(@"指纹/面部ID不正确，认证失败");
        } else if(state == YZAuthIDStateTouchIDLockout) {
            XHQHUDErrorText(@"多次错误，指纹/面部ID已被锁定，请到手机解锁界面输入密码");
        } else if(state == YZAuthIDStateUserCancel){
            [self authIDVerify];
        } else if (state == YZAuthIDStateSuccess) {
            //登录
            [self gotoMainView];
        }
    }];
}

@end
